// 路由跳转方法
import { useRouter } from "vue-router";

/**
 *跳转页面 
 */
const useJump = ()=>{
	const router = useRouter();
	// 跳转页面
	const jumpTo = (path:string ,query = {},params = {})=>{
		if(query){
			router.push({
				path,
				query
			})
		}else{
			router.push({
				path,
				params
			})
		}
	} 
	//跳转登录页面
	const toLogin = ()=>{
		jumpTo('/login')
	} 
	// 返回上一个页面
	const back = ()=>{
		// router.go(-1)
		router.back();
	}
	
	return{
		jumpTo,
		toLogin,
		back
	}
}

export default useJump;
